import Vue from 'vue'
import VueRouter from 'vue-router'
const Home = () => import( /* webpackChunkName: "router-group" */ '../views/Home.vue');
const SingerTypeList = () => import( /* webpackChunkName: "router-group" */ '../components/singer/SingerTypeList.vue');
const MusicList = () => import( /* webpackChunkName: "router-group" */ '../components/music/MusicList.vue');
const MusicTypeList = () => import( /* webpackChunkName: "router-group" */ '../components/music/MusicTypeList.vue');
const MvList = () => import( /* webpackChunkName: "router-group" */ '../components/mv/MvList.vue');
const NewsList = () => import( /* webpackChunkName: "router-group" */ '../components/news/NewsList.vue');
const NewsTypeList = () => import( /* webpackChunkName: "router-group" */ '../components/news/NewsTypeList.vue');
const SingerList = () => import( /* webpackChunkName: "router-group" */ '../components/singer/SingerList.vue');
const ManagerList = () => import( /* webpackChunkName: "router-group" */ '../components/system/ManagerList.vue');
const UserList = () => import( /* webpackChunkName: "router-group" */ '../components/system/UserList.vue');
const Login = () => import( /* webpackChunkName: "router-group" */ '../views/Login.vue');
const GedanList = () => import( /* webpackChunkName: "router-group" */ '../components/gedan/GedanList');
const Index = () => import( /* webpackChunkName: "router-group" */ '../components/Index/Index.vue');
const GedanTypeList = () => import( /* webpackChunkName: "router-group" */ '../components/gedan/GedanTypeList');

Vue.use(VueRouter)

const routes = [{
  path: '/login',
  component: Login
}, {
  path: '/',
  redirect: '/login',
}, {
  path: '/home',
  redirect: '/index',
  component: Home,
  children: [{
      path: '/managerlist',
      component: ManagerList
    },
    {
      path: '/index',
      component: Index
    },
    {
      path: '/userlist',
      component: UserList
    },
    {
      path: '/musictypelist',
      component: MusicTypeList
    },
    {
      path: '/musiclist',
      component: MusicList
    },
    {
      path: '/mvlist',
      component: MvList
    },
    {
      path: '/singertypelist',
      component: SingerTypeList
    },
    {
      path: '/singerlist',
      component: SingerList
    },
    {
      path: '/newstypelist',
      component: NewsTypeList
    },
    {
      path: '/newslist',
      component: NewsList
    },
    {
      path: '/gedanlist',
      component: GedanList
    },
    {
      path: '/gedantypelist',
      component: GedanTypeList
    },
  ]
}]


const router = new VueRouter({
  routes
})

router.beforeEach(function (to, from, next) {
  if (to.path == '/login') {
    return next();
  }
  var token = window.sessionStorage.getItem('token');
  if (!token) {
    return next('/login');
  }
  next();
})

export default router